package se.study.thread;

import java.io.IOException;

/**
 * @Author: tiger
 * @Date:2018/5/10
 * @Description:进程学习
 */
public class ProcessStudy {
    public static void main(String[] args) {
        createPro();
        createPro2();
    }

    /**
     * 通过 ProcessBuilder 创建进程
     */
    private static void createPro2() {
        try {
            ProcessBuilder processBuilder = new ProcessBuilder();
            processBuilder.command("notepad");
            processBuilder.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 通过 Runtime 类的 exec() 方法来创建进程
     */
    private static void createPro() {
        Runtime runtime = Runtime.getRuntime();
        try {
            runtime.exec("notepad");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
